{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6a8e6279",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2022-2023-02\n",
    "\n",
    "Python Data Analysis Course(PDAC)\n",
    "\n",
    "主讲：周圳\n",
    "\n",
    "week03:数据思维训练（计算和分类）"
   ]
  },
  {
   "attachments": {
    "image-2.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAAGKCAYAAACo6/OBAAAfrklEQVR4nO3de5hV1Z2n8ffUFTwFVgEFaAkURUCBiERyUUERjFHpURo0l07SzvTETOIkPZ2kx3T3RCed6dgzMT25TDsdjdO5dCfxif3knokSfXJTg21ICEQQLxhERRkpQKiCgio488faRw5lFQVSrFW1eT/Pc57a+5xdZ//2oaj9rbXXWhskSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkJTUfKB3h8Rvgy8BbgJGJakzpXRz58+nvsQWYl6BeSZKGtAJwBbAL2AS8GajKnh8LLAMezh6Ls+dPJlXA+whh4ifA5D62KQATgRuA9mzbD8cqUJKk4eRM4LfAPYSg0dso4B8IweQ9QE280oaEcovQbQzc4nMWsAL4J8LnJmmYq0pdgHSS2Q18gvCX/meBP0hbzpC2AfgQcBowNXEtkgaBoUOKbyvw99nynwEtEfd9KvAZ+m6FGYoeBb4CvCF1IZKOn6FDSuM3wH3AIuDyiPstEoLHcPID4DH8fSUNe/4nltLYSQgeAAuJ12dhJnB6pH0Nll3AA8DB1IVIOj6GDimNEvBEtjwLmBBhn0Xg7Qz9UTPVhHBUn7oQSYPL0CGl82z2dR4nNnRUAdMJo2beewL3M1jqgGuAhtSFHKU6YA4wJXUh0lBn6JDS2QasyZZb+9lmLPAfCP0ayvNW7CL0B/kgR+4QWh6+ewB4HLg2e/6ybN+9J+J61wD1FggtEH8DrKz4vk3ANwl9UwajdaKJ/j+POsIxjwXmAu8kDKn9WK86zwG+RP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QUGAgpyPUU0v7+ftaPjLSqlp5SGvz/c8TjY3nPADxjYGDtc7Zv39H2orpQ4YILhqqLZ7K0zxWINWvXsmfv3txFqaHC/BXDw8NX7Lrssis6UUyvyxqIJ4Cft7KQHvbvsPwffJ9bZabTBUiSJEmSJEmSJEmSJEmSJEmSmuZ/nxobhWWyKToAAAAASUVORK5CYII="
    }
   },
   "cell_type": "markdown",
   "id": "3100037d",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "# 基本的数据结构（P31)\n",
    "![image.png](attachment:image.png)\n",
    "![image-2.png](attachment:image-2.png)\n",
    "# Series\n",
    "# DataFrame\n",
    "# 常用基本函数\n",
    "* 汇总函数 \n",
    "* 特征统计函数\n",
    "* 唯一值函数\n",
    "* 替换函数\n",
    "* 排序函数\n",
    "# Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ddc175f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "10b8dfa2",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = pd.Series(\n",
    "    data = [100,'a',{'dict1',5}],\n",
    "    index = pd.Index([1,2,3],name='my_idx'),\n",
    "    dtype = 'object',\n",
    "    name = 'my_name'\n",
    "             )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3c4f9418",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "my_idx\n",
       "1           100\n",
       "2             a\n",
       "3    {dict1, 5}\n",
       "Name: my_name, dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "00164cbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = pd.Series(\n",
    "    data = [67,78,75],\n",
    "    index = pd.Index(['数学','语文','英语'],name='学科')\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3c9abe55",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "学科\n",
       "数学    67\n",
       "语文    78\n",
       "英语    75\n",
       "dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ce3e182d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([67, 78, 75], dtype=int64)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "84f14521",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['数学', '语文', '英语'], dtype='object', name='学科')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ecb20c68",
   "metadata": {},
   "outputs": [],
   "source": [
    "s2 = pd.Series(\n",
    "    data = [67,78,75],\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d08e868f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    67\n",
       "1    78\n",
       "2    75\n",
       "dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "682dec0a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "67"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "836578f2",
   "metadata": {},
   "source": [
    "# DataFrame\n",
    "* 具有相同特征和个数的列表数据的集合，可以用DataFrame来描述"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e7ee209f",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = [\n",
    "    [1,'a',1.2],\n",
    "    [2,'b',2.2],\n",
    "    [3,'c',3.2]\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0ecb66dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(\n",
    "    data = data,\n",
    "    index = ['row_0','row_1','row_2'],\n",
    "    columns = ['col_0','col_1','col_2']\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b0c27041",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col_0</th>\n",
       "      <th>col_1</th>\n",
       "      <th>col_2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row_0</th>\n",
       "      <td>1</td>\n",
       "      <td>a</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_1</th>\n",
       "      <td>2</td>\n",
       "      <td>b</td>\n",
       "      <td>2.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_2</th>\n",
       "      <td>3</td>\n",
       "      <td>c</td>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       col_0 col_1  col_2\n",
       "row_0      1     a    1.2\n",
       "row_1      2     b    2.2\n",
       "row_2      3     c    3.2"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b75465d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {\n",
    "    'col_0':[1,2,3],\n",
    "    'col_1':['a','b','c'],\n",
    "    'col_2':[1.2,2.2,3.2]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "fb7c3ccc",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(\n",
    "    data = data,\n",
    "    index = ['row_0','row_1','row_2']\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "417422f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col_0</th>\n",
       "      <th>col_1</th>\n",
       "      <th>col_2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row_0</th>\n",
       "      <td>1</td>\n",
       "      <td>a</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_1</th>\n",
       "      <td>2</td>\n",
       "      <td>b</td>\n",
       "      <td>2.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_2</th>\n",
       "      <td>3</td>\n",
       "      <td>c</td>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       col_0 col_1  col_2\n",
       "row_0      1     a    1.2\n",
       "row_1      2     b    2.2\n",
       "row_2      3     c    3.2"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5fab71c6",
   "metadata": {},
   "source": [
    "# df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "e1d5870e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "row_0    1\n",
       "row_1    2\n",
       "row_2    3\n",
       "Name: col_0, dtype: int64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['col_0']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "36c29520",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col_0</th>\n",
       "      <th>col_2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row_0</th>\n",
       "      <td>1</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_1</th>\n",
       "      <td>2</td>\n",
       "      <td>2.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_2</th>\n",
       "      <td>3</td>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       col_0  col_2\n",
       "row_0      1    1.2\n",
       "row_1      2    2.2\n",
       "row_2      3    3.2"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['col_0','col_2']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "03de397e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col_1</th>\n",
       "      <th>col_2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row_1</th>\n",
       "      <td>b</td>\n",
       "      <td>2.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_2</th>\n",
       "      <td>c</td>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col_1  col_2\n",
       "row_1     b    2.2\n",
       "row_2     c    3.2"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[1:3,1:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa909534",
   "metadata": {},
   "source": [
    "* 课后练习(参考 pandas cheat sheet)："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "87e6bbe4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 'a', 1.2],\n",
       "       [2, 'b', 2.2],\n",
       "       [3, 'c', 3.2]], dtype=object)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ba1b44b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['row_0', 'row_1', 'row_2'], dtype='object')"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c04b0dea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['col_0', 'col_1', 'col_2'], dtype='object')"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0096ff30",
   "metadata": {},
   "source": [
    "# 常用基本函数\n",
    "* 汇总函数\n",
    "* 特征统计函数\n",
    "* 唯一值函数\n",
    "* 替换函数\n",
    "* 排序函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd38f92a",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['School'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93f8a7b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.query(\" School ==  'Peking University'\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a123903",
   "metadata": {},
   "source": [
    "# 实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9c85ea7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>排名</td>\n",
       "      <td>排名变化</td>\n",
       "      <td>企业名称</td>\n",
       "      <td>价值（亿元人民币）</td>\n",
       "      <td>价值变化（亿元人民币）</td>\n",
       "      <td>国家</td>\n",
       "      <td>城市</td>\n",
       "      <td>行业</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>抖音</td>\n",
       "      <td>13400</td>\n",
       "      <td>-10050</td>\n",
       "      <td>中国</td>\n",
       "      <td>北京</td>\n",
       "      <td>社交媒体</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>SpaceX</td>\n",
       "      <td>8400</td>\n",
       "      <td>1680</td>\n",
       "      <td>美国</td>\n",
       "      <td>洛杉矶</td>\n",
       "      <td>航天</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>-1</td>\n",
       "      <td>蚂蚁集团</td>\n",
       "      <td>8000</td>\n",
       "      <td>-2010</td>\n",
       "      <td>中国</td>\n",
       "      <td>杭州</td>\n",
       "      <td>金融科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>Stripe</td>\n",
       "      <td>4100</td>\n",
       "      <td>-2210</td>\n",
       "      <td>美国</td>\n",
       "      <td>旧金山</td>\n",
       "      <td>金融科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>95</td>\n",
       "      <td>-16</td>\n",
       "      <td>Impossible 食品</td>\n",
       "      <td>470</td>\n",
       "      <td>0</td>\n",
       "      <td>美国</td>\n",
       "      <td>雷德伍德城</td>\n",
       "      <td>食品饮料</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>95</td>\n",
       "      <td>-16</td>\n",
       "      <td>微医</td>\n",
       "      <td>470</td>\n",
       "      <td>0</td>\n",
       "      <td>中国</td>\n",
       "      <td>杭州</td>\n",
       "      <td>健康科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>99</td>\n",
       "      <td>58</td>\n",
       "      <td>蜂巢能源</td>\n",
       "      <td>460</td>\n",
       "      <td>190</td>\n",
       "      <td>中国</td>\n",
       "      <td>常州</td>\n",
       "      <td>新能源</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>99</td>\n",
       "      <td>-6</td>\n",
       "      <td>Better.com</td>\n",
       "      <td>460</td>\n",
       "      <td>60</td>\n",
       "      <td>美国</td>\n",
       "      <td>纽约</td>\n",
       "      <td>金融科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>99</td>\n",
       "      <td>-20</td>\n",
       "      <td>Automation Anywhere</td>\n",
       "      <td>460</td>\n",
       "      <td>-10</td>\n",
       "      <td>美国</td>\n",
       "      <td>圣何塞</td>\n",
       "      <td>人工智能</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>102 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      0     1                    2          3            4   5      6     7\n",
       "0    排名  排名变化                 企业名称  价值（亿元人民币）  价值变化（亿元人民币）  国家     城市    行业\n",
       "1     1     0                   抖音      13400       -10050  中国     北京  社交媒体\n",
       "2     2     1               SpaceX       8400         1680  美国    洛杉矶    航天\n",
       "3     3    -1                 蚂蚁集团       8000        -2010  中国     杭州  金融科技\n",
       "4     4     0               Stripe       4100        -2210  美国    旧金山  金融科技\n",
       "..   ..   ...                  ...        ...          ...  ..    ...   ...\n",
       "97   95   -16        Impossible 食品        470            0  美国  雷德伍德城  食品饮料\n",
       "98   95   -16                   微医        470            0  中国     杭州  健康科技\n",
       "99   99    58                 蜂巢能源        460          190  中国     常州   新能源\n",
       "100  99    -6           Better.com        460           60  美国     纽约  金融科技\n",
       "101  99   -20  Automation Anywhere        460          -10  美国    圣何塞  人工智能\n",
       "\n",
       "[102 rows x 8 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "hurun_独角兽 = pd.read_html('https://www.hurun.net/zh-CN/Info/Detail?num=L9SQPH9FKJB1')[-3]\n",
    "hurun_独角兽"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3028f8d7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
